package com.bigshen.demo.annotation.injectioncomponents.a1propertysource;

import com.bigshen.demo.project.entity.Child;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;

public class MyTest {

    @Test
    public void test() {

        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MyConfig.class);

        Child child = (Child) applicationContext.getBean("child");
        System.out.println(child);

        // 从environment中获取配置文件属性
        Environment environment = applicationContext.getEnvironment();
        String propertyValue = environment.getProperty("child.family");
        System.out.println(propertyValue);

    }

}
